// pages/income/income.js
const app = getApp()
var config = require('../../config.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },
   menuArrow: function (e) {
    this.setData({
      menuArrow: e.detail.value
    });
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var workerWageFlowId = options.workerWageFlowId;
    that.queryInfo(workerWageFlowId);
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },

  /**
   * 获取信息
   */
  queryInfo: function (workerWageFlowId) {
    wx.showLoading({
      title: '加载中',
    })
    var that = this;
    let searchData = {
      param: '{' +
        '"workerWageFlowId": "' + workerWageFlowId + '"}'
    }
    wx.request({
      url: config.queryJournalAccountInfo,
      method: 'POST',
      header: {
        "content-type": "application/x-www-form-urlencoded"
      },
      data: searchData,
      success: function (result) {
        wx.hideLoading();
        console.info("收支列详情询返回结果");
        console.info(result);
        var data = result.data.object;
        var company = data.company;
        var order = data.o;
        var settlement = data.settlement;
        var worker = data.worker;
        console.info(data);
        that.setData({
          companyCode: company.companyCode,
          companyName: company.companyName,
          content: company.content,
          industryTypeName: data.industryType.industryTypeName,
          linkMan: company.linkMan,
          companyPhone: company.phone,
          companyAddress: company.address,
          orderCode: order.orderCode,
          orderTime: order.orderTime,
          orderTitle: order.orderTitle,
          taskDescription: order.taskDescription,
          qualifications: order.qualifications,
          effectiveTime: order.effectiveTime,
          workAddress: order.workAddress,
          orderStatus: order.orderStatus,
          businessTypeName: data.businessType.businessTypeName,
          billingUnit: order.billingUnit,
          unitPrice: order.unitPrice,
          generalTask: order.generalTask,
          demandPopulation: order.demandPopulation,
          totalCost: order.totalCost,
          settlementStatus: order.settlementStatus,
          settlementNo: settlement.settlementNo,
          settlementTime: settlement.createTime,
          workerCode: worker.workerCode,
          workerName: worker.name,
          workerPhone: worker.phone,
          idCard: worker.idCard,
          settlementGeneralTask: data.generalTask,
          realTotalPayable: settlement.realTotalPayable,
          workerWageFlowId: data.workerWageFlowId,
          transactionTime: data.transactionTime,
          transactionAmount: data.transactionAmount,
          transactionType: data.transactionType,
          tradeType: '费用结算'
        });

      },
      fail: function ({ errMsg }) {
        console.info("收支详情查询失败");
        wx.hideLoading();
      },
    });
  }

})